/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.apt.Bean;

import java.sql.Connection;
import java.sql.PreparedStatement;
import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apt.connectDB.MyConnect;

/**
 *
 * @author MinhThang
 */
public class update_lecture extends org.apache.struts.action.ActionForm {
    
   private String txtTitle;
   private String txtSummary;
   private String editorDefault;
   private String ddlDisplay;
   private String txtDescription;
   private String txtID;
    public update_lecture() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * @return the txtTitle
     */
    public String getTxtTitle() {
        return txtTitle;
    }

    /**
     * @param txtTitle the txtTitle to set
     */
    public void setTxtTitle(String txtTitle) {
        this.txtTitle = txtTitle;
    }

    /**
     * @return the txtSummary
     */
    public String getTxtSummary() {
        return txtSummary;
    }

    /**
     * @param txtSummary the txtSummary to set
     */
    public void setTxtSummary(String txtSummary) {
        this.txtSummary = txtSummary;
    }

    /**
     * @return the editorDefault
     */
    public String getEditorDefault() {
        return editorDefault;
    }

    /**
     * @param editorDefault the editorDefault to set
     */
    public void setEditorDefault(String editorDefault) {
        this.editorDefault = editorDefault;
    }

    public boolean UpdateLecture(int ID){
        //Update data to Lecture table
        Connection conn=null;
        PreparedStatement ps=null;
        String sql="UPDATE Lecture SET Title=?, Summary=?,Content=?,Status=?,Description=? WHERE LectureID=?";
        String choose=getDdlDisplay();
        boolean status=true;
        if(choose.equalsIgnoreCase("Unable")){
            status=false;
        }
        try {
            conn=MyConnect.getConnection();
            ps=conn.prepareCall(sql);
            ps.setString(1, getTxtTitle());
            ps.setString(2, getTxtSummary());
            ps.setString(3, getEditorDefault());
            ps.setBoolean(4, status);
            ps.setString(5, getTxtDescription());
            ps.setInt(6, ID);
            ps.executeUpdate();
            return true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    /**
     * @return the ddlDisplay
     */
    public String getDdlDisplay() {
        return ddlDisplay;
    }

    /**
     * @param ddlDisplay the ddlDisplay to set
     */
    public void setDdlDisplay(String ddlDisplay) {
        this.ddlDisplay = ddlDisplay;
    }

    /**
     * @return the txtDescription
     */
    public String getTxtDescription() {
        return txtDescription;
    }

    /**
     * @param txtDescription the txtDescription to set
     */
    public void setTxtDescription(String txtDescription) {
        this.txtDescription = txtDescription;
    }

    /**
     * @return the txtID
     */
    public String getTxtID() {
        return txtID;
    }

    /**
     * @param txtID the txtID to set
     */
    public void setTxtID(String txtID) {
        this.txtID = txtID;
    }
    /**
     * This is the action called from the Struts framework.
     * @param mapping The ActionMapping used to select this instance.
     * @param request The HTTP Request we are processing.
     * @return
     */
   
}
